package com.li.singlepattern;

/**
 * 懒汉式1-单例
 * 通过测试，多线程下会产生多个对象-漏洞
 * 加上synchronized同步锁可以解决：please read RoleModel2.class
 *
 * @author lirenchun
 */
public class RoleModel1 {
    /**
     * 私有化构造器
     */
    private RoleModel1() {
    }

    private static RoleModel1 roleModel = null;

    public static RoleModel1 getInstance() {
        if (roleModel == null) {
            roleModel = new RoleModel1();
        }
        return roleModel;
    }
}
